
#pragma once

#include <iostream>
#include <pthread.h>
#include "Mutex.hpp"
using namespace std;

class Cond
{
public:
    Cond()
    {
        int n = pthread_cond_init(&cond,nullptr);
    }
    void Wait(Mutex &mutex)
    {
        pthread_cond_wait(&cond,mutex.Get());
    }
    void Signal()
    {
        pthread_cond_signal(&cond);
    }
    void Broadcast()
    {
        pthread_cond_broadcast(&cond);
    }
    ~Cond()
    {
        int n = pthread_cond_destroy(&cond);
    }
private:
    pthread_cond_t cond;

};
